function clearFilter(){
	divId = 'innercontainer';
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	
	$.ajax({
		type: "POST",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",	
		url: appRoot+'/common/process/setFilterNew.jsp',
		data : 'jtkn='+token+'&type=FILTER',
		async: false,
	  	success: function(response){
			doFilterResult (response,'');
  		}
	});	
}

function doFilter() {
	var filterElemsDiv = document.getElementById("filterContainerDiv");
	var elms = filterElemsDiv.getElementsByTagName("*");
	var loadDivParams = '';
	for ( var i = 0, maxI = elms.length; i < maxI; ++i) 
	{
		var paramName = '';
		var paramValue = '';
		var elm = elms[i];
		switch (elm.type) {
		case "text":
			paramName = elm.id;
			paramValue = encodeURIComponent(elm.value);
			break;
		case "textarea":
			paramName = elm.id;
			paramValue = encodeURIComponent(elm.value);
			break;
		case "hidden":
			paramName = elm.id;
			paramValue = encodeURIComponent(elm.value);
		case "reset":
			break;
		case "submit":
			break;
		case "radio":
			break;
		case "checkbox":
			break;
		case "select-one":
			paramName = elm.id;
			
			if(elm.selectedIndex>=0)
			paramValue = elm.options[elm.selectedIndex].value;
			else
				paramValue = -1;
			break;
		case "select-multiple":
			break;
			
		}
		if (paramName != '' && (elm.type == "text" || elm.type == "hidden" || paramValue != ''))
			loadDivParams += '&paramName=' + paramName + '&' + paramName + '='+ paramValue;
	}

	divId = 'innercontainer';
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	
	$.ajax({
		type: "POST",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",	
		url: appRoot+'/common/process/setFilterNew.jsp',
		data : 'jtkn='+token+loadDivParams+'&type=FILTER',
		async: false,
	  	success: function(response){
			doFilterResult (response,loadDivParams);
  		}
	});	
}

function doFilterResult(result, params){
	var qs = new Querystring(decodeURI(result));
	var qs2 = new Querystring(decodeURI(params));
	var divId = qs.get('divId');
	var pagePath = qs.get('pagePath');
	$('#'+divId).load(appRoot+pagePath+'?jtkn='+token)
}

function loadSelect(selectId, url, params, required, empty, endFunc) {
	var param = 'jtkn=' + params;
	var inputLoader = new JimetInputLoaderObj();

	if (empty == true) {
		var sel = document.getElementById(selectId);
		for (i = sel.length - 1; i >= 0; i--) {
			sel.options[i] = null;
		}
		var grps = sel.getElementsByTagName("optgroup");
		for (i = grps.length - 1; i >= 0; i--) {
			sel.removeChild(grps[i]);
		}
	}
	if (endFunc)
		inputLoader.setEndFunc(endFunc);

	inputLoader.doLoad(selectId, url, param, required);
	
	$('#'+selectId+' option:last-child').attr("selected", "selected");
}

function toggleFilterDiv()
{
	if($(".filter_on").length > 0)
	{
		
		$('.filter').slideUp('slow', function() {$('.filter').html('');$(".filter").removeClass("filter_on");$('.filterapplied').slideDown('slow', function() {})});
	}
	else
	{
		if ( $('.filterapplied').length > 0 )
			$('.filter').load(appRoot+'/common/includes/commonSearchTable.jsp?jtkn='+token, function(){$('.filterapplied').slideUp('slow', function() {$('.filter').slideDown('slow', function() {})});} );
		else
			$('.filter').load(appRoot+'/common/includes/commonSearchTable.jsp?jtkn='+token, function(){$('.filter').slideDown('slow', function() {})} );
		$(".filter").addClass("filter_on");
	}

}

function selectAllForTable ( type ) 
{
	if ( type == '1' )
		$('input:checkbox.actionSB').attr('checked',true);
	else
		$('input:checkbox.actionSB').attr('checked',false);
}

function checkSB ( selectedIx , action )
{	
	var selection	=  document.getElementsByName('actionSB');
	for ( i=0 ; i<selection.length ; i++)
	{
		if ( selectedIx == i )
			selection[i].checked	= true;
		else
			selection[i].checked	= false;
	}
	if ( action )
	{
		tableAction	=  document.getElementById('tableAction');
		tableAction.selectedIndex = action - 1;
	}
}

function processTableAction (frmId , token , processPage, processPageIx )
{
	var tableAction = $('#tableAction').val();
	var url = appRoot+'/common/process/confirmProcessTable.jsp';
	var params = '?jtkn='+token+'&processPage='+ processPage +'&processPageIx='+processPageIx + '&tableAction='+tableAction;
	var selectedIds	= '';
	var checkedInputs = $('#actionSB:checked');
	
	for ( i=0 ; i<checkedInputs.length ; i++)
		selectedIds += checkedInputs[i].value +',';

	params += '&objIds='+selectedIds;

	$('#confirmDialog').load(url+params ,function(){showConfirmDialog()});	
}

function showConfirmDialog () {
	$('#confirmDialog').modal({backdrop: 'static', show:true , keyboard : true});
};	

function loadPage ( divId , pg , pgIx , objId )
{
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	
	$.ajax({
		type: "POST",
		contentType: "application/x-www-form-urlencoded; charset=utf-8",	
		url: appRoot+'/common/process/preProcess.jsp',
		data : 'jtkn='+token+'&processPage='+pg+'&processPageIx='+pgIx+'&objId='+objId,
		async: false,
	  	success: function(response){
			$.globalEval(response);
  		}
	});	
}
 
function nextPage(){
	var divId = $("#divId").val();
	var pagePath = $("#pagePath").val();
	var pageParams = $("#pageParams").val();
	var pageNum 	= Number($("#pageNum").val())+1;
	var currentPage = $("#currentPage").val();
	if( pageNum == currentPage )
	{
		return false;
	}
	
	pageParams += '&currentPage='+pageNum; 
	
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	loadDiv.ajaxStop(function() {$(this).hide();});
	
	$('#'+divId).load(appRoot+pagePath+'?jtkn='+token+pageParams);
}

function previousPage(){
	
	var divId = $("#divId").val();
	var pagePath = $("#pagePath").val();
	var pageParams =  $("#pageParams").val();
	var pageNum 	= Number($("#pageNum").val())-1;
	var currentPage = $("#currentPage").val();
	if( pageNum == currentPage )
	{
		return false;
	}
	
	pageParams += '&currentPage='+pageNum; 
	
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	loadDiv.ajaxStop(function() {$(this).hide();});
	
	$('#'+divId).load(appRoot+pagePath+'?jtkn='+token+pageParams);
}

function pageNumLingPress(pageNum)
{
	var divId = $("#divId").val();
	var pagePath = $("#pagePath").val();
	var pageParams = $("#pageParams").val();
	var currentPage = $("#currentPage").val();
	if( pageNum == currentPage )
	{
		return false;
	}
	
	pageParams += '&currentPage='+pageNum; 
	
	if ( $('#'+divId+'Loading').length == 0 ){
		$("#"+divId).append("<div id=\""+divId+"Loading\" class=\"loadingDiv\"></div>");
	}
	loadDiv = $('#'+divId+'Loading');
	var mypos = $('#'+divId).position();
	loadDiv.css({top: mypos.top + "px"});
	loadDiv.height($('#'+divId).height());
	loadDiv.width($('#'+divId).width());
	loadDiv.hide();
	loadDiv.ajaxStart(function() {$(this).show();});
	loadDiv.ajaxStop(function() {$(this).hide();});
	
	$('#'+divId).load(appRoot+pagePath+'?jtkn='+token+pageParams);

}